package com.huike.clues.service.impl;


import com.huike.clues.domain.TbClueTrackRecord;
import com.huike.clues.domain.vo.ClueTrackRecordVo;
import com.huike.clues.mapper.TbClueTrackRecordMapper;
import com.huike.clues.service.ITbClueTrackRecordService;
import com.huike.common.core.page.TableDataInfo;
import com.huike.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 线索跟进记录Service业务层处理
 * @date 2022-04-22
 */


@Service
public class TbClueTrackRecordServiceImpl implements ITbClueTrackRecordService {
@Autowired
private TbClueTrackRecordMapper tbClueTrackRecordMapper;
    @Override
    public boolean add(ClueTrackRecordVo tbClueTrackRecord) {
        TbClueTrackRecord trackRecord=new TbClueTrackRecord();
        trackRecord.setClueId(tbClueTrackRecord.getClueId());
        trackRecord.setFalseReason(tbClueTrackRecord.getFalseReason());
        trackRecord.setLevel(tbClueTrackRecord.getLevel());
        trackRecord.setNextTime(tbClueTrackRecord.getNextTime());
        trackRecord.setSubject(tbClueTrackRecord.getSubject());
        trackRecord.setRecord(tbClueTrackRecord.getRecord());
        trackRecord.setType(tbClueTrackRecord.getType());
        trackRecord.setCreateBy(SecurityUtils.getUsername());
        boolean add = tbClueTrackRecordMapper.insert(trackRecord);
        return add;
    }

    @Override
    public TableDataInfo select(Long clueId) {
        List<TbClueTrackRecord> tbClueTrackRecord = tbClueTrackRecordMapper.selectByClueId(clueId);
        int size = tbClueTrackRecord.size();
        TableDataInfo tableDataInfo=new TableDataInfo();

        if(size==0){
return null;
            }
        tableDataInfo.setRows(tbClueTrackRecord);
        tableDataInfo.setCode(200);
        tableDataInfo.setMsg("查询成功");
        tableDataInfo.setParams(null);
        return tableDataInfo;
    }
}
